package mdt.figure;

import org.tigris.gef.presentation.FigText;
import mdt.model.INodeModel;

import java.awt.*;

public class FigMultiLineText extends FigTextMDT implements FigMDT{

    private static final long serialVersionUID = 1L;

		private void initFigs() {
            setReturnAction(FigText.INSERT);
            setTabAction(FigText.END_EDITING);
            setJustification(FigText.JUSTIFY_CENTER);
            setFilled(false);
            setLineWidth(0);
    }

    /**
     * Create a multi line text Fig
     *
     * @param owner      owning UML element
     * @param bounds     position and size
     */
    public FigMultiLineText(INodeModel owner, Rectangle bounds) {
        super(bounds.x, bounds.y, bounds.width, bounds.height);
        initFigs();
        setOwner(owner);
    }

    public FigMultiLineText(INodeModel owner) {
        this(owner, new Rectangle(X0, Y0, 0, 0));
    }

    public int getArcLength() {
        int arcWidth = 12 + Math.max(0, (getWidth() - 20) / 12 * 2);
        int arcHeight = 12 + Math.max(0, (getHeight() - 20) / 12 * 2);
        return Math.min(arcWidth, arcHeight);
    }

    @Override
    public void renderingChanged() {
        damage();
    }

    @Override
    public void translateCloned(int dx, int dy) {

    }
}
